package com.mantru.iotpot.job;

import com.mantru.iotpot.modbus.Common;
import com.mantru.iotpot.ApplicationClass;
import org.json.JSONObject;

/**
 * 录制的炒菜步骤实体类
 */
public class RecordSteepEntity {
    //步骤类型：1加热设置、2调味料投放、3料盒投放、4手动投放
    public int steep_type;
    //步骤序号，从1开始
    public int steep_index;
    //锅档位，0-9档，值越大表示火力越大
    public int fire_value;
    //开始时长的缩写格式，格式mm:ss
    public String time_value;
    //开始时长，将time_value转换为秒的值，单位：秒
    public int time_long;
    //机械爪转速，0-5档，steep_type=1时有效
    public int gripper_speed_value;
    //机械爪转向，0正方向、1反方向、2周期正反转，steep_type=1时有效
    public int gripper_rotation_value;
    //机械爪位置，1放下、2抬起，steep_type=1时有效
    public int gripper_position_value;

    //生抽，单位：克，这里是第1喷嘴，在t_public_config_newpot.device_param_001字段里配置了g、ml和秒的转换公式，steep_type=2时有效
    public int nozzle1_value;
    //老抽，单位：克，这里是第2喷嘴，在t_public_config_newpot.device_param_002字段里配置了g、ml和秒的转换公式，steep_type=2时有效
    public int nozzle2_value;
    //蚝油，单位：克，这里是第3喷嘴，在t_public_config_newpot.device_param_003字段里配置了g、ml和秒的转换公式，steep_type=2时有效
    public int nozzle3_value;
    //动物油A，单位：克，这里是第4喷嘴，在t_public_config_newpot.device_param_004字段里配置了g、ml和秒的转换公式，steep_type=2时有效
    public int nozzle4_value;
    //动物油B，单位：克，这里是第5喷嘴，在t_public_config_newpot.device_param_005字段里配置了g、ml和秒的转换公式，steep_type=2时有效
    public int nozzle5_value;
    //植物油，单位：克，这里是第6喷嘴，在t_public_config_newpot.device_param_006字段里配置了g、ml和秒的转换公式，steep_type=2时有效
    public int nozzle6_value;
    //盐水，单位：克，这里是第7喷嘴，在t_public_config_newpot.device_param_007字段里配置了g、ml和秒的转换公式，steep_type=2时有效
    public int nozzle7_value;
    //醋，单位：克，这里是第8喷嘴，在t_public_config_newpot.device_param_008字段里配置了g、ml和秒的转换公式，steep_type=2时有效
    public int nozzle8_value;
    //淀粉水，单位：克，这里是第9喷嘴，在t_public_config_newpot.device_param_009字段里配置了g、ml和秒的转换公式，steep_type=2时有效
    public int nozzle9_value;
    //烹饪水，单位：克，这里是第10喷嘴，在t_public_config_newpot.device_param_010字段里配置了g、ml和秒的转换公式，steep_type=2时有效
    public int nozzle10_value;
    //洗锅水，单位：克，这里是第11喷嘴，在t_public_config_newpot.device_param_011字段里配置了g、ml和秒的转换公式，steep_type=2时有效
    public int nozzle11_value;
    //料盒1里填放的品相名称，steep_type=3时有效
    public String box1_name;
    //料盒1里填放的品相重量，单位：克，steep_type=3时有效
    public int box1_value;
    //料盒2里填放的品相名称，steep_type=3时有效
    public String box2_name;
    //料盒2里填放的品相重量，单位：克，steep_type=3时有效
    public int box2_value;
    //料盒3里填放的品相名称，steep_type=3时有效
    public String box3_name;
    //料盒3里填放的品相重量，单位：克，steep_type=3时有效
    public int box3_value;
    //料盒4里填放的品相名称，steep_type=3时有效
    public String box4_name;
    //料盒4里填放的品相重量，单位：克，steep_type=3时有效
    public int box4_value;
    //投菜避让：1是、0否，steep_type=3时有效
    public int box_need_avoid;
    //投菜方式：1常规投菜（投两下）、2慢速投菜（滞留几秒后归位，不抖动）、3快速投菜（投三下）、4慢速投菜（投三下），steep_type=3时有效
    public int box_release_type;
    public int box_index;
    public String box_data;   //{"name":"青菜","value":100}
    //自动语音播报文本
    public String tts_text;
    //创建时间
    public String create_time;
    //最后一步录制的时间ms
    public long last_record_time;

    public RecordSteepEntity(){
        steep_index = 0;
        time_value = "";
        box1_name = "";
        box2_name = "";
        box3_name = "";
        box4_name = "";
        tts_text = "";
        box_data = "";
        gripper_position_value = 1;
        last_record_time = 0;
        create_time = Common.GetDataTimeString();
    }

    public String ToString() {
        //步骤类型：1加热设置、2调味料投放、3料盒投放、4手动投放
        if (steep_type == 1) tts_text = "加热设置";
        if (steep_type == 2) tts_text = "调味料投放";
        if (steep_type == 3) tts_text = "料盒投放";
        if (steep_type == 4) tts_text = "手动投放";

        String str = "";
        if (steep_type == 1)
            str = "{\"steep_type\":\"" + steep_type + "\""
                + ",\"steep_index\":\"" + steep_index + "\""
                + ",\"fire_value\":\"" + fire_value + "\""
                + ",\"time_value\":\"" + time_value + "\""
                + ",\"time_long\":\"" + time_long + "\""
                + ",\"gripper_speed_value\":\"" + gripper_speed_value + "\""
                + ",\"gripper_rotation_value\":\"" + gripper_rotation_value + "\""
                + ",\"gripper_position_value\":\"" + gripper_position_value + "\""
                + ",\"nozzle1_value\":\"0\""
                + ",\"nozzle2_value\":\"0\""
                + ",\"nozzle3_value\":\"0\""
                + ",\"nozzle4_value\":\"0\""
                + ",\"nozzle5_value\":\"0\""
                + ",\"nozzle6_value\":\"0\""
                + ",\"nozzle7_value\":\"0\""
                + ",\"nozzle8_value\":\"0\""
                + ",\"nozzle9_value\":\"0\""
                + ",\"nozzle10_value\":\"0\""
                + ",\"nozzle11_value\":\"0\""
                + ",\"box1_name\":\"\""
                + ",\"box1_value\":\"0\""
                + ",\"box2_name\":\"\""
                + ",\"box2_value\":\"0\""
                + ",\"box3_name\":\"\""
                + ",\"box3_value\":\"0\""
                + ",\"box4_name\":\"\""
                + ",\"box4_value\":\"0\""
                + ",\"box_need_avoid\":\"0\""
                + ",\"box_release_type\":\"0\""
                + ",\"create_time\":\"" + create_time + "\""
                + ",\"tts_text\":\"" + tts_text + "\"}";
        if (steep_type == 2)
            str = "{\"steep_type\":\"" + steep_type + "\""
                    + ",\"steep_index\":\"" + steep_index + "\""
                    + ",\"fire_value\":\"0\""
                    + ",\"time_value\":\"" + time_value + "\""
                    + ",\"time_long\":\"" + time_long + "\""
                    + ",\"gripper_speed_value\":\"0\""
                    + ",\"gripper_rotation_value\":\"0\""
                    + ",\"gripper_position_value\":\"0\""
                    + ",\"nozzle1_value\":\"" + nozzle1_value + "\""
                    + ",\"nozzle2_value\":\"" + nozzle2_value + "\""
                    + ",\"nozzle3_value\":\"" + nozzle3_value + "\""
                    + ",\"nozzle4_value\":\"" + nozzle4_value + "\""
                    + ",\"nozzle5_value\":\"" + nozzle5_value + "\""
                    + ",\"nozzle6_value\":\"" + nozzle6_value + "\""
                    + ",\"nozzle7_value\":\"" + nozzle7_value + "\""
                    + ",\"nozzle8_value\":\"" + nozzle8_value + "\""
                    + ",\"nozzle9_value\":\"" + nozzle9_value + "\""
                    + ",\"nozzle10_value\":\"" + nozzle10_value + "\""
                    + ",\"nozzle11_value\":\"" + nozzle11_value + "\""
                    + ",\"box1_name\":\"\""
                    + ",\"box1_value\":\"0\""
                    + ",\"box2_name\":\"\""
                    + ",\"box2_value\":\"0\""
                    + ",\"box3_name\":\"\""
                    + ",\"box3_value\":\"0\""
                    + ",\"box4_name\":\"\""
                    + ",\"box4_value\":\"0\""
                    + ",\"box_need_avoid\":\"0\""
                    + ",\"box_release_type\":\"0\""
                    + ",\"create_time\":\"" + create_time + "\""
                    + ",\"tts_text\":\"" + tts_text + "\"}";
        if (steep_type == 3)
            str = "{\"steep_type\":\"" + steep_type + "\""
                    + ",\"steep_index\":\"" + steep_index + "\""
                    + ",\"fire_value\":\"0\""
                    + ",\"time_value\":\"" + time_value + "\""
                    + ",\"time_long\":\"" + time_long + "\""
                    + ",\"gripper_speed_value\":\"0\""
                    + ",\"gripper_rotation_value\":\"0\""
                    + ",\"gripper_position_value\":\"0\""
                    + ",\"nozzle1_value\":\"0\""
                    + ",\"nozzle2_value\":\"0\""
                    + ",\"nozzle3_value\":\"0\""
                    + ",\"nozzle4_value\":\"0\""
                    + ",\"nozzle5_value\":\"0\""
                    + ",\"nozzle6_value\":\"0\""
                    + ",\"nozzle7_value\":\"0\""
                    + ",\"nozzle8_value\":\"0\""
                    + ",\"nozzle9_value\":\"0\""
                    + ",\"nozzle10_value\":\"0\""
                    + ",\"nozzle11_value\":\"0\""
                    + ",\"box1_name\":\"" + box1_name + "\""
                    + ",\"box1_value\":\"" + box1_value + "\""
                    + ",\"box2_name\":\"" + box2_name + "\""
                    + ",\"box2_value\":\"" + box2_value + "\""
                    + ",\"box3_name\":\"" + box3_name + "\""
                    + ",\"box3_value\":\"" + box3_value + "\""
                    + ",\"box4_name\":\"" + box4_name + "\""
                    + ",\"box4_value\":\"" + box4_value + "\""
                    + ",\"box_need_avoid\":\"" + box_need_avoid + "\""
                    + ",\"box_release_type\":\"" + box_release_type + "\""
                    + ",\"box_data\":[" + box_data + "]"
                    + ",\"create_time\":\"" + create_time + "\""
                    + ",\"tts_text\":\"" + tts_text + "\"}";

        return str;
    }

}
